package ${controllerPackage};

import ${serviceJava};
import ${voJava};
import ${addDtoJava};
import ${changeDtoJava};
import ${listDtoJava};
import ${pageDtoJava};
import ${removeDtoJava};
import ${serviceJava};
import java.util.List;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import ${commonResultJava};
import ${pageVoJava};

/**
 * ${tableComment} controller
 *
 * @author ${createUser}
 * @since ${createTime}
 */
@RestController
@RequestMapping(value = "/${clsName?uncap_first}")
@Api(tags = "${tableComment} ${controllerName}")
public class ${controllerName} {

    @Resource
    private ${serviceName} ${serviceName?uncap_first};

    @ApiOperation(value = "添加${tableComment}")
    @PostMapping("/add")
    public CommonResult<Boolean> add(${addDtoName} ${addDtoName?uncap_first}){
        ${serviceName?uncap_first}.add( ${addDtoName?uncap_first});
        return CommonResult.success(true);
    }

    @ApiOperation(value = "删除${tableComment}")
    @DeleteMapping("/remove")
    public CommonResult<Boolean> remove(${removeDtoName} ${removeDtoName?uncap_first}){
        ${serviceName?uncap_first}.remove( ${removeDtoName?uncap_first});
        return CommonResult.success(true);
    }

    @ApiOperation(value = "修改${tableComment}")
    @PutMapping("/change")
    public CommonResult<Boolean> change(${changeDtoName} ${changeDtoName?uncap_first}){
        ${serviceName?uncap_first}.change( ${changeDtoName?uncap_first});
        return CommonResult.success(true);
    }

    @ApiOperation(value = "查询${tableComment}列表")
    @GetMapping("/list")
    public CommonResult<List<${voName}>> list(${listDtoName} ${listDtoName?uncap_first}){
        List<${voName}> ${voName?uncap_first}List = ${serviceName?uncap_first}.list(${listDtoName?uncap_first});
        return CommonResult.success(${voName?uncap_first}List);
    }

    @ApiOperation(value = "查询${tableComment}列表(分页)")
    @GetMapping("/page")
    public CommonResult<PageVo<${voName}>> page(${pageDtoName} ${clsName?uncap_first}){
        PageVo<${voName}> ${voName?uncap_first}Page = ${serviceName?uncap_first}.page(${clsName?uncap_first});
        return CommonResult.success(${voName?uncap_first}Page);
    }
}